<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" MaintainScrollPositionOnPostback="true"
    CodeFile="ManageScoreRanges.aspx.cs" Inherits="Admin_ManageScoreRanges" Title="APM - Score Ranges" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="ranges">
        <ul id="path">
            <li><a href="../Home.aspx">Home</a> &gt;</li>
            <li>Administration &gt;</li>
            <li>Score Ranges</li>
        </ul>
        <h3 class="ranges"><span>Score Ranges</span></h3>
        <div id="content">
            <p>
            </p>
            <table width="100%">
                <tr>
                    <td colspan="2" style="font-weight: bold; height: 25px; vertical-align: top">
                        Add new Score Range
                    </td>
                </tr>
                <asp:Panel runat="server" ID="pnlError">
                <tr>
                    <td colspan="2">
                        <asp:Label ID="lblMsg2" runat="server" Font-Bold="true">Score Range Status: </asp:Label>
                        <asp:Label ID="lblMsg" runat="server" ForeColor="red">Error</asp:Label>
                        <br />
                        <asp:Label ID="lblMsg3" runat="server" Font-Bold="true">Status Details: </asp:Label>
                        <asp:Label ID="lblMsg4" runat="server" ForeColor="red">The score generated by the Risk Impact Assessment Questionnaire is greater than the max Score Range defined in the system </asp:Label>
                    </td>
                </tr>
                </asp:Panel>
                <tr>
                    <td colspan="2">
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td style="width: 130px;">
                                    Score Range Name
                                </td>
                                <td>
                                    <table cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <asp:TextBox runat="server" ID="txtScoreName" Width="100" MaxLength="50" CssClass="input"></asp:TextBox></td>
                                            <td>
                                                &nbsp;&nbsp;Example - Critical
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td style="width: 130px;"> 
                                    Score Range Top Value
                                </td>
                                <td>
                                    <table cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <asp:TextBox runat="server" ID="txtThreshold" Width="100" MaxLength="7" CssClass="input"></asp:TextBox></td>
                                            <td>
                                                &nbsp;&nbsp;Example - 550
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button runat="server" ID="btnSave" Text="Submit" ToolTip="Click to add new Score Range"
                            ValidationGroup="Add" CausesValidation="true" OnClick="btnSave_Click" />
                        <asp:ValidationSummary runat="server" HeaderText="Please correct the following:"
                            ShowMessageBox="true" ValidationGroup="Add" ID="valiAllValidations" ShowSummary="false"
                            DisplayMode="BulletList" />
                        <asp:RequiredFieldValidator ID="reqScoreName" runat="server" SetFocusOnError="true"
                            Display="None" ValidationGroup="Add" ControlToValidate="txtScoreName" ErrorMessage=" Required Field: Score Range Name "></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regexScoreName" runat="server" ControlToValidate="txtScoreName"
                            ErrorMessage="Invalid Input: Score Range Name " ValidationGroup="Add" ValidationExpression="<%$ AppSettings:ScoreRangeNameRegEx %>"
                            Display="None" SetFocusOnError="true"></asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="reqThreshold" runat="server" SetFocusOnError="true"
                            Display="None" ControlToValidate="txtThreshold" ValidationGroup="Add" ErrorMessage=" Required Field: Score Range Top Value "></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ValidationGroup="Add" SetFocusOnError="true" ID="regThresholdValue"
                            runat="server" ControlToValidate="txtThreshold" ErrorMessage="Invalid Input: Score Range Top Value"
                            ValidationExpression="^[0-9]+$" Display="None"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Existing Score Ranges
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:GridView CssClass="table" Width="100%" AllowPaging="True" EmptyDataText="There are no score ranges defined in system."
                            AllowSorting="true" DataKeyNames="ScoreID" PageSize="10" ToolTip="This table displays all the score ranges in the APM System"
                            DataSourceID="obdsScoreRange" ID="gridScoreRanges" runat="server" AutoGenerateColumns="False" OnRowDataBound="Grid_RowDataBound"
                            AutoGenerateEditButton="false" OnRowUpdated="Grid_RowUpdated" OnRowDeleted="Grid_RowDeleted">
                            <AlternatingRowStyle CssClass="alternate" />
                            <PagerSettings Position="TopAndBottom" />
                            <PagerStyle CssClass="pages" />
                            <HeaderStyle BackColor="#6699CC" HorizontalAlign="Left" />
                            <EmptyDataRowStyle BackColor="#C4D7D6" />
                            <Columns>
                                <asp:CommandField ItemStyle-Width="10px" ValidationGroup="Update" ShowCancelButton="true"
                                    ShowEditButton="true" HeaderText="Select" ButtonType="link" CausesValidation="true"
                                    HeaderStyle-HorizontalAlign="left" ItemStyle-HorizontalAlign="left" ShowDeleteButton="true">
                                    <ItemStyle Width="110px" Wrap="False" />
                                    </asp:CommandField>
                                <asp:TemplateField HeaderText="Score Range Name" SortExpression="1">
                                    <ItemTemplate>
                                        <%# Microsoft.Security.Application.AntiXss.HtmlEncode(Eval("ScoreName").ToString()) %>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtScoreID" Visible="false" ReadOnly="true" runat="Server" Text='<%# Bind("ScoreID") %>' />
                                        <asp:TextBox ID="txtScoreName" runat="Server" Text='<%# Bind("ScoreName") %>' MaxLength="50"
                                            CssClass="input" />
                                        <asp:RequiredFieldValidator ID="reqName" runat="server" ControlToValidate="txtScoreName"
                                            ErrorMessage="Required Field: Score Range Name" Display="None" SetFocusOnError="True"
                                            ValidationGroup="Update"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="regexName" runat="server" ControlToValidate="txtScoreName"
                                            ErrorMessage="Invalid Input: Score Range Name" SetFocusOnError="True" ValidationExpression="<%$ AppSettings:ScoreRangeNameRegEx %>"
                                            Display="None" ValidationGroup="Update"></asp:RegularExpressionValidator>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="ScoreRangeValue" HeaderText="Score Range" ReadOnly="true" ItemStyle-Width="250px"
                                    SortExpression="2" />
                            </Columns>
                            <RowStyle HorizontalAlign="Left" />
                        </asp:GridView>
                        <asp:ValidationSummary ID="vsScoreRange" runat="server" HeaderText="Please correct the following:"
                            ShowMessageBox="true" ShowSummary="false" ValidationGroup="Update" DisplayMode="BulletList" />
                        <asp:ObjectDataSource ID="obdsScoreRange" runat="server" TypeName="Microsoft.AceEngineering.SPM.SPMBusinessLayer.ScoreRangeBL"
                            SelectMethod="GetAllScoreData" SelectCountMethod="GetCountScoreData" MaximumRowsParameterName="noOfrows"
                            StartRowIndexParameterName="startIndex" EnablePaging="true" UpdateMethod="SaveScoreRangeChanges" DeleteMethod="DeleteScoreRange"
                            SortParameterName="sortexp">
                            <UpdateParameters>
                                <asp:ControlParameter Name="ScoreName" ControlID="txtScoreName" PropertyName="Text" />
                                <asp:FormParameter Name="ScoreID" FormField="txtScoreID" />
                                <asp:SessionParameter Name="createdBy" SessionField="loginname" Type="String" />
                            </UpdateParameters>
                            <DeleteParameters>
                               <asp:Parameter Name="ScoreID" Type="String" />
                            </DeleteParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="2"> 
                        Note: These Score Ranges map to the task lists within the workflow. So ensure that the
                        max Score Range defined
                        <br />
                        in the system is greater than any possible score generated for the Risk Impact Assessment
                        Questionnaire.
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
